<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: libemb::MutexCond Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>libemb</b></li><li class="navelem"><a class="el" href="classlibemb_1_1_mutex_cond.html">MutexCond</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classlibemb_1_1_mutex_cond-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">libemb::MutexCond Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>条件变量  
 <a href="classlibemb_1_1_mutex_cond.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_thread_util_8h_source.html">ThreadUtil.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for libemb::MutexCond:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classlibemb_1_1_mutex_cond.png" usemap="#libemb::MutexCond_map" alt=""/>
  <map id="libemb::MutexCond_map" name="libemb::MutexCond_map">
<area href="classlibemb_1_1_mutex.html" title="互斥锁类" alt="libemb::Mutex" shape="rect" coords="0,0,118,24"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0d038456e6c24f7621f47deec97e9e31"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_mutex_cond.html#a0d038456e6c24f7621f47deec97e9e31">wait</a> (int usec=-1)</td></tr>
<tr class="memdesc:a0d038456e6c24f7621f47deec97e9e31"><td class="mdescLeft">&#160;</td><td class="mdescRight">等待条件变量  <a href="classlibemb_1_1_mutex_cond.html#a0d038456e6c24f7621f47deec97e9e31">More...</a><br /></td></tr>
<tr class="separator:a0d038456e6c24f7621f47deec97e9e31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66ed5d2571fba8731139e51c90ada598"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_mutex_cond.html#a66ed5d2571fba8731139e51c90ada598">meet</a> ()</td></tr>
<tr class="memdesc:a66ed5d2571fba8731139e51c90ada598"><td class="mdescLeft">&#160;</td><td class="mdescRight">通知等待者满足条件变量  <a href="classlibemb_1_1_mutex_cond.html#a66ed5d2571fba8731139e51c90ada598">More...</a><br /></td></tr>
<tr class="separator:a66ed5d2571fba8731139e51c90ada598"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classlibemb_1_1_mutex"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classlibemb_1_1_mutex')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classlibemb_1_1_mutex.html">libemb::Mutex</a></td></tr>
<tr class="memitem:a05691334e33086ce5e2155d8082fba60 inherit pub_methods_classlibemb_1_1_mutex"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_mutex.html#a05691334e33086ce5e2155d8082fba60">lock</a> ()</td></tr>
<tr class="memdesc:a05691334e33086ce5e2155d8082fba60 inherit pub_methods_classlibemb_1_1_mutex"><td class="mdescLeft">&#160;</td><td class="mdescRight">互斥锁上锁  <a href="classlibemb_1_1_mutex.html#a05691334e33086ce5e2155d8082fba60">More...</a><br /></td></tr>
<tr class="separator:a05691334e33086ce5e2155d8082fba60 inherit pub_methods_classlibemb_1_1_mutex"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8ff4ef59bf0b51a1477678d78f5ecb4a inherit pub_methods_classlibemb_1_1_mutex"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_mutex.html#a8ff4ef59bf0b51a1477678d78f5ecb4a">unLock</a> ()</td></tr>
<tr class="memdesc:a8ff4ef59bf0b51a1477678d78f5ecb4a inherit pub_methods_classlibemb_1_1_mutex"><td class="mdescLeft">&#160;</td><td class="mdescRight">互斥锁解锁  <a href="classlibemb_1_1_mutex.html#a8ff4ef59bf0b51a1477678d78f5ecb4a">More...</a><br /></td></tr>
<tr class="separator:a8ff4ef59bf0b51a1477678d78f5ecb4a inherit pub_methods_classlibemb_1_1_mutex"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a57785fab2eadfa4bd7012fd4b44010ce inherit pub_methods_classlibemb_1_1_mutex"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_mutex.html#a57785fab2eadfa4bd7012fd4b44010ce">tryLock</a> ()</td></tr>
<tr class="memdesc:a57785fab2eadfa4bd7012fd4b44010ce inherit pub_methods_classlibemb_1_1_mutex"><td class="mdescLeft">&#160;</td><td class="mdescRight">互斥锁尝试上锁  <a href="classlibemb_1_1_mutex.html#a57785fab2eadfa4bd7012fd4b44010ce">More...</a><br /></td></tr>
<tr class="separator:a57785fab2eadfa4bd7012fd4b44010ce inherit pub_methods_classlibemb_1_1_mutex"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>条件变量 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a66ed5d2571fba8731139e51c90ada598"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a66ed5d2571fba8731139e51c90ada598">&#9670;&nbsp;</a></span>meet()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::MutexCond::meet </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>通知等待者满足条件变量 </p>
<dl class="section return"><dt>Returns</dt><dd>int </dd></dl>

</div>
</div>
<a id="a0d038456e6c24f7621f47deec97e9e31"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0d038456e6c24f7621f47deec97e9e31">&#9670;&nbsp;</a></span>wait()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::MutexCond::wait </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>usec</em> = <code>-1</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>等待条件变量 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">usec,超时时间,&lt;0时阻塞等待,&gt;=0时等待usec</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功等到条件变量返回STATUS_OK,超时返回STATUS_TIMEOUT,失败返回STATUS_ERROR <div class="fragment"><div class="line">多个线程不可以同时调用wait()方法,必需使用lock进行互斥,例程:</div>
<div class="line">        线程A                              线程B</div>
<div class="line">        ...                              ...</div>
<div class="line">        cond.<a class="code" href="classlibemb_1_1_mutex.html#a05691334e33086ce5e2155d8082fba60">lock</a>();                        cond.<a class="code" href="classlibemb_1_1_mutex.html#a05691334e33086ce5e2155d8082fba60">lock</a>();      </div>
<div class="line">        while(pass==0)                   pass=1;</div>
<div class="line">        {                                cond.meet();</div>
<div class="line">           cond.wait(100);               con.unlock();</div>
<div class="line">        }                                ...</div>
<div class="line">        cond.unlock();</div>
<div class="line">        ...</div>
</div><!-- fragment --> </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/<a class="el" href="_thread_util_8h_source.html">ThreadUtil.h</a></li>
<li>src/ThreadUtil.cpp</li>
</ul>
</div><!-- contents -->
<div class="ttc" id="aclasslibemb_1_1_mutex_html_a05691334e33086ce5e2155d8082fba60"><div class="ttname"><a href="classlibemb_1_1_mutex.html#a05691334e33086ce5e2155d8082fba60">libemb::Mutex::lock</a></div><div class="ttdeci">int lock()</div><div class="ttdoc">互斥锁上锁</div><div class="ttdef"><b>Definition:</b> ThreadUtil.cpp:65</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
